# HG changeset patch # User Mads Kiilerich # Date 1687807901 -7200 # Mon Jun 26 21:31:41 2023 +0200 # Node ID ff25ec7c3af036cdb39ac141e7b6e778611fbf34 # Parent 922b708e00ab7feb246d682132010185d9ced11d tests: use packaging from setuptools instead of deprecated distutils When invoking StrictVersion in 3.12 we got: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. distutils is dead in the standard library, and we have to move towards using `setuptools` as general extern dependency. Instead of also requiring the extern `packaging`, we will just use the packaging that is vendored in setuptools. diff --git a/tests/hghave.py b/tests/hghave.py --- a/tests/hghave.py +++ b/tests/hghave.py @@ -1,4 +1,3 @@ -import distutils.version import os import re import socket @@ -7,6 +6,11 @@ import subprocess import sys import tempfile +try: + from setuptools.extern.packaging.version import Version +except ImportError: + from distutils.version import StrictVersion as Version + tempprefix = 'hg-hghave-' checks = { @@ -1118,16 +1122,18 @@ def has_black(): blackcmd = 'black --version' version_regex = b'black, (?:version )?([0-9a-b.]+)' version = matchoutput(blackcmd, version_regex) - sv = distutils.version.StrictVersion - return version and sv(_bytes2sys(version.group(1))) >= sv('23.3.0') + if not version: + return False + return Version(_bytes2sys(version.group(1))) >= Version('23.3.0') @check('pytype', 'the pytype type checker') def has_pytype(): pytypecmd = 'pytype --version' version = matchoutput(pytypecmd, b'[0-9a-b.]+') - sv = distutils.version.StrictVersion - return version and sv(_bytes2sys(version.group(0))) >= sv('2019.10.17') + if not version: + return False + return Version(_bytes2sys(version.group(0))) >= Version('2019.10.17') @check("rustfmt", "rustfmt tool at version nightly-2021-11-02") _______________________________________________ Mercurial-devel mailing list Mercurial-devel@lists.mercurial-scm.org https://lists.mercurial-scm.org/mailman/listinfo/mercurial-devel